var GPYNo = -1;//打开的摄像头编号
var DevCount = 0;
//设备初始化
function ChoseDev()
{
	alertMsg.correct("正在初始化设备，请稍候...");
	var  ret = GPRActiveX.SSCMRSetGPYNo(2);
	if(ret != 0)
	{
		return false;
	}
	return true;
}
//读取身份证 return String
function ReadIdentityCard()
{
	var f=ChoseDev();
	if(!f){
		alertMsg.warn("设备初始化错误")
		return "";
	}
	var iret =  GPRActiveX.iReadIdentityCard(1);
	var result=	GPRActiveX.OutInfo;
	if(iret>=0){
		return result.split("|")[5];
	}else{
		alertMsg.warn("未放置身份证或设备未连接")
		return "";
	}	
}

//开启摄像头
function SS_CMR_Open()
{
	 var f=ChoseDev();
	if(!f){
		alertMsg.warn("设备初始化错误")
	} 
 	var iCamNo = document.getElementById("CamNo").value;	
    var ret = GPRActiveX.SSCMROpen(iCamNo);
	if(ret == 0)
	{
		GPYNo = iCamNo;
		if(iCamNo == 2)
		{
			alertMsg.warn("无2号摄像头！");
		}
		else
		{
		  //alert("打开摄像头成功");
		}
	}
	else
	{
		alertMsg.warn("打开摄像头失败");
	}
}
//关闭摄像头
function SS_CMR_Close()
{
    var ret = GPRActiveX.SSCMRClose(GPYNo);  
    GPYNo = -1;
    
}

//获取摄像头当前状态
function SS_CMR_GetStatus()
{
    var ret = GPRActiveX.SSCMRGetStatus(GPYNo);

    if(ret ==1)
    {
    	alertMsg.correct("设备处于打开可用状态");
    }
    else if(ret == 2)
    {
    	alertMsg.correct("设备正忙");
    }
    else if(ret == 3)
    {
    	alertMsg.correct("设备处于硬件故障状态");
    }
    else if(ret == 4)
    {
    	alertMsg.correct("设备处于关闭状态");
    }
    else
    {
    	alertMsg.correct("其他状态");
    }
                                  
}